﻿using DBFile.Core.Configuration;
using DBFile.Core.Interfaces;

namespace DBFile.Providers
{
    public abstract class DBFileProviderBase : DBFileProvider
    {
        protected IDBFileProvider _provider = null;
        protected object padLock = new object();

        public override bool Exists(string filename)
        {
            return Provider.Exists(filename);
        }

        public override int Copy(string sourceFilename, string destinationFilename, bool overwrite)
        {
            return Provider.Copy(sourceFilename, destinationFilename, overwrite);
        }

        public override int Insert(string filename, byte[] buffer, string contentType, long contentLength)
        {
            return Provider.Insert(filename, buffer, contentType, contentLength, false);
        }

        public override int Insert(string filename, byte[] buffer, string contentType, long contentLength, bool overwrite)
        {
            return Provider.Insert(filename, buffer, contentType, contentLength, overwrite);
        }

        public override int Update(string filename, byte[] buffer, string contentType, long contentLength)
        {
            return Provider.Update(filename, buffer, contentType, contentLength);
        }

        public override int Delete(string filename)
        {
            return Provider.Delete(filename);
        }

        public override string[] GetFileNameList()
        {
            return Provider.GetFileNameList();
        }

        public override T Get<T>(string filename)
        {
            return Provider.Get<T>(filename);
        }
                
        protected abstract IDBFileProvider Provider { get; }
    }
}
